<!DOCTYPE html>
<html class="x-admin-sm">

{include file="common/static" /}
{include file="common/resources" /}
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">房间管理</a>
                <a>
                    <cite>楼层设置</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            <div class="layui-input-inline layui-show-xs-block">
                                <input type="text" name="username" placeholder="请输入楼层" autocomplete="off" class="layui-input" id="storey">
                            </div>
                            <button class="layui-btn" onclick="adds()">
                                <i class="layui-icon"></i>添加</button>
                        </div>
                        <div class="layui-card-body ">
                            <table class="layui-table layui-form" lay-even lay-skin="line">
                                <thead>
                                <tr>

                                    <th>ID</th>
                                    <th>楼层</th>

                                    <th>创建时间</th>
                                    <th>操作</th></tr>
                                </thead>
                                <tbody>
                                {volist name='list' id='vo'}
                                <tr>
                                    <td>
                                        <img src="/static/ico/id.png"/>
                                        {$vo.id}
                                    </td>
                                    <td>
                                        <strong>{$vo.storey}</strong>
                                        <img src="/static/ico/storey.png"/>
                                    </td>

                                    <td>
                                        <img src="/static/ico/time.png"/>
                                        {:date('Y-m-d H:i:s',$vo.create_time)}
                                    </td>
                                    <td class="td-manage">
                                        <a title="查看" onclick="xadmin.open('编辑','/home/storeys/edits/id/'+{$vo.id},500,200)" href="javascript:;">
                                            <i class="layui-icon">&#xe63c;</i></a>
                                        <a title="删除" onclick="member_del(this,{$vo.id})" href="javascript:;">
                                            <i class="layui-icon">&#xe640;</i></a>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                            {$list|raw}
                        </div>
<!--                        <div class="layui-card-body ">
                            <div class="page">
                                <div>
                                    <a class="prev" href="">&lt;&lt;</a>
                                    <a class="num" href="">1</a>
                                    <span class="current">2</span>
                                    <a class="num" href="">3</a>
                                    <a class="num" href="">489</a>
                                    <a class="next" href="">&gt;&gt;</a></div>
                            </div>
                        </div>-->
                    </div>
                </div>
            </div>
        </div>
    </body>

<script>layui.use(['laydate', 'form'],
        function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
            });
        });

    /*楼层-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？',
        function(index) {
            $.ajax({
                type:"post",
                url: "{:url('home/storeys/deletes')}",
                data: {
                    id:id
                },
                success: function(data){
                    console.log(data);
                    toastr.error(data.msg);
                    if(data.code == 100){
                        layer.closeAll();
                        $(obj).parents("tr").remove();
                    }
                }});
        });
    }
    /*楼层添加*/
    function adds(){
        $.ajax({
            type:"post",
            url: "{:url('home/storeys/adds')}",
            data: {
                storey:$('#storey').val(),

            },
            success: function(data){
                console.log(data);
                toastr.error(data.msg);
                if(data.code == 100){
                    setTimeout(function () {
                        layer.closeAll();
                        location.reload();
                    },1500);
                }
            }});
    }
</script>


</html>